﻿Public Class frmFiltroPorPeriodo


    Private _dtInicial As Date
    Public Property dtIncial() As Date
        Get
            Return _dtInicial
        End Get
        Set(ByVal value As Date)
            _dtInicial = value
        End Set
    End Property
    Private _dtFinal As Date
    Public Property dtFinal() As Date
        Get
            Return _dtFinal
        End Get
        Set(ByVal value As Date)
            _dtFinal = value
        End Set
    End Property
    Private Function validaSelecao() As Boolean
        If dtIncial > dtFinal Then
            MsgBox("Data Incial deve ser menor que data final")
            Return False
        Else
            Return True
        End If

    End Function

    Private Sub frmFiltroPorPeriodo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtDtInicial.Format = DateTimePickerFormat.Short
        txtDtFinal.Format = DateTimePickerFormat.Short
    End Sub

    Private Sub btnCancela_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancela.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub btnSelecionarData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelecionarData.Click

        Me.dtIncial = txtDtInicial.Text
        Me.dtFinal = txtDtFinal.Text
        If validaSelecao() Then
            Me.DialogResult = Windows.Forms.DialogResult.OK
            Me.Close()
        End If

    End Sub
End Class